#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
# - http://www.zhengzhong.net/
# - http://blog.zhengzhong.net/
#
# Wrappers for google.appengine.api.users module.
#
# Created on 2008-12-19.
# $Id: users.py 310 2008-12-30 13:28:29Z heavyzheng $
#

from django.http import HttpRequest
from google.appengine.api import users

class AppUser(object):

    def __init__(self, google_user):
        self._google_user = google_user
    
    def __nonzero__(self):
        return self._google_user is not None
    
    def nickname(self):
        if self._google_user is not None:
            return self._google_user.nickname()
        else:
            return None
    
    def email(self):
        if self._google_user is not None:
            return self._google_user.email()
    
    def google_user(self):
        return self._google_user


def get_current_user(request):
    return AppUser(users.get_current_user())

def create_login_url(redirect_url):
    return users.create_login_url(redirect_url)

def create_logout_url(redirect_url):
    return users.create_logout_url(redirect_url)

#

